function output = specifygui(gid)

string = cellstr(get(gid,'String'));
string = string(~strcmp('All',string)&~strcmp('Specify',string));

gui.nobuttons        = [1 length(string)+1];       % 1st col: dropdown, 2nd col: edit, 3rd col: checkboxes, 4th col:buttons
gui.buttondistance   = [20 5];
gui.buttonsize       = [200 20];
gui.figuresize       = (gui.buttonsize+gui.buttondistance).*(gui.nobuttons)+gui.buttondistance;
gui.uipositions(:,1) = sort(repmat(round(linspace(gui.buttondistance(1),gui.figuresize(1)-gui.buttondistance(1)-gui.buttonsize(1),gui.nobuttons(1))'),gui.nobuttons(2),1));
gui.uipositions(:,2) = repmat(round(linspace(gui.buttondistance(2),gui.figuresize(2)-gui.buttondistance(2)-gui.buttonsize(2),gui.nobuttons(2))'),gui.nobuttons(1),1);

if ~isfield(gui,'fid');
    gui.fid          = figure(10);
    set(gui.fid,'position',[50 50 gui.figuresize]); else figure(gui.fid);
end

for n=1:length(string)
    gui.h.(string{n})       = uicontrol('Value',0,'Style','checkbox');
end
    
gui.h.start                 = uicontrol('Style','togglebutton','String','Confirm');
    
% Modifies GUI positions
gui.uifields          = fieldnames(gui.h);
gui.checkboxcount     = 1; n=1; m=1;
while n<=length(gui.uifields);
switch get(gui.h.(char(gui.uifields(n,:))),'Style')
    case 'checkbox'
    set(gui.h.(char(gui.uifields(n,:))),'position',[gui.uipositions(m,:) gui.buttonsize],'String',char(gui.uifields(n,:)));
    set(gui.h.(char(gui.uifields(n,:))),'Backgroundcolor',get(gui.fid,'color'));
    otherwise
    set(gui.h.(char(gui.uifields(n,:))),'position',[gui.uipositions(m,:) gui.buttonsize]);
    set(gui.h.(char(gui.uifields(n,:))),'Backgroundcolor',get(gui.fid,'color'));
end
n=n+1; m=m+1;
end

while 1
    pause(0.1);
    if get(gui.h.start,'Value'); 
        break; end;
end

output ={};

for n=1:length(string)
    if get(gui.h.(char(gui.uifields(n,:))),'value')
    output = [output,get(gui.h.(char(gui.uifields(n,:))),'String')];
    end
end

close(gui.fid)
end